﻿using System;
using Ant.Interface.Mef;

namespace Ant.Interface.Log
{
    /// <summary>
    /// 日志控制接口。
    /// </summary>
    public interface ILogController : ISingletonDependency
    {
        /// <summary>
        /// 设置记录器。
        /// </summary>
        /// <param name="loggerType">记录器类型。</param>
        void SetLogger(Type loggerType);

        /// <summary>
        /// 设置记录器。
        /// </summary>
        /// <param name="loggerName">记录器名称。</param>
        /// <param name="loggerType">记录器类型。</param>
        void SetLogger(string loggerName, Type loggerType = null);

        /// <summary>
        /// 输出调试信息
        /// </summary>
        /// <param name="categoryName">业务类型</param>
        /// <param name="message">描述信息</param>
        /// <param name="exception">异常</param>
        void Debug(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 输出错误信息。
        /// </summary>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="message">信息。</param>
        /// <param name="exception">异常。</param>
        void Error(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 输出致命错误信息。
        /// </summary>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="message">信息。</param>
        /// <param name="exception">异常。</param>
        void Fatal(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 输出信息。
        /// </summary>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="message">信息。</param>
        /// <param name="exception">异常。</param>
        void Info(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 输出追踪信息。
        /// </summary>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="message">信息。</param>
        /// <param name="exception">异常。</param>
        void Trace(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 输出警告信息。
        /// </summary>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="message">信息。</param>
        /// <param name="exception">异常。</param>
        void Warn(string categoryName, string message, Exception exception = null);

        /// <summary>
        /// 监控。
        /// </summary>
        /// <param name="action">执行的动作。</param>
        /// <param name="categoryName">分类名称。</param>
        /// <param name="actionDescription">动作说明。</param>
        /// <param name="errorAction">错误时执行的动作。</param>
        /// <param name="finallyAction">最后执行的动作。</param>
        /// <param name="startInfo">动作开始时的信息格式。</param>
        /// <param name="endInfo">动作结束时的信息格式。</param>
        /// <param name="errorInfo">执行动作错误时的信息格式。</param>
        /// <param name="finallyInfo">动作执行最后时的信息格式。</param>
        /// <param name="isFatal">如果发生错误是否是致命错误。</param>
        /// <param name="isMonitorLog">时间记录监控的日志。</param>
        /// <param name="isThrowError">动作执行失败是否抛出异常。</param>
        void Monitor(Action action, string categoryName, string actionDescription, Action<Exception> errorAction = null, Action finallyAction = null, string startInfo = "开始{0}。", string endInfo = "{0}成功。", string errorInfo = "{0}失败。", string finallyInfo = null, bool isFatal = false, bool isMonitorLog = true, bool isThrowError = true);
    }
}